package com.echo.code.spring.springbootdemo.async;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * Description
 *
 * @author baiyp
 * @version 1.0.0
 * @date 2019/04/28
 */
@Service
@Slf4j
public class AsyncTaskService {

  @Async
  public void print(int i) {
    try {
      TimeUnit.SECONDS.sleep(1);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    log.info("{}: {}", Thread.currentThread().getName(), i);
  }
}
